home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / python / pythnlbn.lha / python-lib.info-4 < prev    next >
Encoding:
GNU Info File  |  1993-07-29  |  48.7 KB  |  1,328 lines

  1. This is Info file python-lib.info, produced by Makeinfo-1.43 from the
  2. input file @out.texi.
  3.  
  4. This file describes the built-in types, exceptions and functions and
  5. the standard modules that come with the Python system.  It assumes
  6. basic knowledge about the Python language.  For an informal
  7. introduction to the language, see the Python Tutorial.  The Python
  8. Reference Manual gives a more formal definition of the language. 
  9. (These manuals are not yet available in INFO or Texinfo format.)
  10.  
  11. Copyright (C) 1991, 1992, 1993 by Stichting Mathematisch Centrum,
  12. Amsterdam, The Netherlands.
  13.  
  14. All Rights Reserved
  15.  
  16. Permission to use, copy, modify, and distribute this software and its
  17. documentation for any purpose and without fee is hereby granted,
  18. provided that the above copyright notice appear in all copies and that
  19. both that copyright notice and this permission notice appear in
  20. supporting documentation, and that the names of Stichting Mathematisch
  21. Centrum or CWI not be used in advertising or publicity pertaining to
  22. distribution of the software without specific, written prior
  23. permission.
  24.  
  25. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  26. THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  27. FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  28. FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  29. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  30. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  31. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  32.  
  33. 
  34. File: python-lib.info,  Node: SGI MACHINES ONLY,  Next: SUN SPARC MACHINES ONLY,  Prev: STDWIN ONLY,  Up: Top
  35.  
  36. SGI MACHINES ONLY
  37. *****************
  38.  
  39. * Menu:
  40.  
  41. * al::                          Built-in Module `al'
  42. * AL (uppercase)::              Standard Module `AL'
  43. * audio::                       Built-in Module `audio'
  44. * gl::                          Built-in Module `gl'
  45. * fm::                          Built-in Module `fm'
  46. * Standard Modules GL and DEVICE::  Standard Modules `GL' and `DEVICE'
  47. * fl::                          Built-in Module `fl'
  48. * FL (uppercase)::              Standard Module `FL'
  49. * flp::                         Standard Module `flp'
  50. * panel::                       Standard Module `panel'
  51. * panelparser::                 Standard Module `panelparser'
  52. * pnl::                         Built-in Module `pnl'
  53. * jpeg::                        Built-in Module `jpeg'
  54. * imgfile::                     Built-in module `imgfile'
  55. * imageop::                     Built-in module `imageop'
  56.  
  57. 
  58. File: python-lib.info,  Node: al,  Next: AL (uppercase),  Up: SGI MACHINES ONLY
  59.  
  60. Built-in Module `al'
  61. ====================
  62.  
  63. This module provides access to the audio facilities of the Indigo and
  64. 4D/35 workstations, described in section 3A of the IRIX 4.0 man pages
  65. (and also available as an option in IRIX 3.3).  You'll need to read
  66. those man pages to understand what these functions do!  Some of the
  67. functions are not available in releases below 4.0.5.  Again, see the
  68. manual to check whether a specific function is available on your
  69. platform.
  70.  
  71. Symbolic constants from the C header file `<audio.h>' are defined in
  72. the standard module `AL', see below.
  73.  
  74. *Warning:* the current version of the audio library may dump core when
  75. bad argument values are passed rather than returning an error status. 
  76. Unfortunately, since the precise circumstances under which this may
  77. happen are undocumented and hard to check, the Python interface can
  78. provide no protection against this kind of problems.  (One example is
  79. specifying an excessive queue size -- there is no documented upper
  80. limit.)
  81.  
  82. Module `al' defines the following functions:
  83.  
  84.  -- function of module al: openport (NAME, DIRECTION, CONFIG)
  85.      Equivalent to the C function ALopenport().  The name and direction
  86.      arguments are strings.  The optional config argument is an opaque
  87.      configuration object as returned by `al.newconfig()'.  The return
  88.      value is an opaque port object; methods of port objects are
  89.      described below.
  90.  
  91.  -- function of module al: newconfig ()
  92.      Equivalent to the C function ALnewconfig().  The return value is
  93.      a new opaque configuration object; methods of configuration
  94.      objects are described below.
  95.  
  96.  -- function of module al: queryparams (DEVICE)
  97.      Equivalent to the C function ALqueryparams().  The device
  98.      argument is an integer.  The return value is a list of integers
  99.      containing the data returned by ALqueryparams().
  100.  
  101.  -- function of module al: getparams (DEVICE, LIST)
  102.      Equivalent to the C function ALgetparams().  The device argument
  103.      is an integer.  The list argument is a list such as returned by
  104.      `queryparams'; it is modified in place (!).
  105.  
  106.  -- function of module al: setparams (DEVICE, LIST)
  107.      Equivalent to the C function ALsetparams().  The device argument
  108.      is an integer.The list argument is a list such as returned by
  109.      `al.queryparams'.
  110.  
  111. Configuration objects (returned by `al.newconfig()' have the following
  112. methods:
  113.  
  114.  -- Method on audio configuration object: getqueuesize ()
  115.      Return the queue size; equivalent to the C function
  116.      ALgetqueuesize().
  117.  
  118.  -- Method on audio configuration object: setqueuesize (SIZE)
  119.      Set the queue size; equivalent to the C function ALsetqueuesize().
  120.  
  121.  -- Method on audio configuration object: getwidth ()
  122.      Get the sample width; equivalent to the C function ALgetwidth().
  123.  
  124.  -- Method on audio configuration object: getwidth (WIDTH)
  125.      Set the sample width; equivalent to the C function ALsetwidth().
  126.  
  127.  -- Method on audio configuration object: getchannels ()
  128.      Get the channel count; equivalent to the C function
  129.      ALgetchannels().
  130.  
  131.  -- Method on audio configuration object: setchannels (NCHANNELS)
  132.      Set the channel count; equivalent to the C function
  133.      ALsetchannels().
  134.  
  135.  -- Method on audio configuration object: getsampfmt ()
  136.      Get the sample format; equivalent to the C function
  137.      ALgetsampfmt().
  138.  
  139.  -- Method on audio configuration object: setsampfmt (SAMPFMT)
  140.      Set the sample format; equivalent to the C function
  141.      ALsetsampfmt().
  142.  
  143.  -- Method on audio configuration object: getfloatmax ()
  144.      Get the maximum value for floating sample formats; equivalent to
  145.      the C function ALgetfloatmax().
  146.  
  147.  -- Method on audio configuration object: setfloatmax (FLOATMAX)
  148.      Set the maximum value for floating sample formats; equivalent to
  149.      the C function ALsetfloatmax().
  150.  
  151. Port objects (returned by `al.openport()' have the following methods:
  152.  
  153.  -- Method on audio port object: closeport ()
  154.      Close the port; equivalent to the C function ALcloseport().
  155.  
  156.  -- Method on audio port object: getfd ()
  157.      Return the file descriptor as an int; equivalent to the C function
  158.      ALgetfd().
  159.  
  160.  -- Method on audio port object: getfilled ()
  161.      Return the number of filled samples; equivalent to the C function
  162.      ALgetfilled().
  163.  
  164.  -- Method on audio port object: getfillable ()
  165.      Return the number of fillable samples; equivalent to the C
  166.      function ALgetfillable().
  167.  
  168.  -- Method on audio port object: readsamps (NSAMPLES)
  169.      Read a number of samples from the queue, blocking if necessary;
  170.      equivalent to the C function ALreadsamples.  The data is returned
  171.      as a string containing the raw data (e.g. 2 bytes per sample in
  172.      big-endian byte order (high byte, low byte) if you have set the
  173.      sample width to 2 bytes.
  174.  
  175.  -- Method on audio port object: writesamps (SAMPLES)
  176.      Write samples into the queue, blocking if necessary; equivalent
  177.      to the C function ALwritesamples.  The samples are encoded as
  178.      described for the `readsamps' return value.
  179.  
  180.  -- Method on audio port object: getfillpoint ()
  181.      Return the `fill point'; equivalent to the C function
  182.      ALgetfillpoint().
  183.  
  184.  -- Method on audio port object: setfillpoint (FILLPOINT)
  185.      Set the `fill point'; equivalent to the C function
  186.      ALsetfillpoint().
  187.  
  188.  -- Method on audio port object: getconfig ()
  189.      Return a configuration object containing the current
  190.      configuration of the port; equivalent to the C function
  191.      ALgetconfig().
  192.  
  193.  -- Method on audio port object: setconfig (CONFIG)
  194.      Set the configuration from the argument, a configuration object;
  195.      equivalent to the C function ALsetconfig().
  196.  
  197.  -- Method on audio port object: getstatus (LIST)
  198.      Get status information on last error equivalent to C function
  199.      ALgetstatus().
  200.  
  201. 
  202. File: python-lib.info,  Node: AL (uppercase),  Next: audio,  Prev: al,  Up: SGI MACHINES ONLY
  203.  
  204. Standard Module `AL'
  205. ====================
  206.  
  207. This module defines symbolic constants needed to use the built-in
  208. module `al' (see above); they are equivalent to those defined in the C
  209. header file `<audio.h>' except that the name prefix `AL_' is omitted. 
  210. Read the module source for a complete list of the defined names. 
  211. Suggested use:
  212.  
  213.      import al
  214.      from AL import *
  215.  
  216. 
  217. File: python-lib.info,  Node: audio,  Next: gl,  Prev: AL (uppercase),  Up: SGI MACHINES ONLY
  218.  
  219. Built-in Module `audio'
  220. =======================
  221.  
  222. *Note:* This module is obsolete, since the hardware to which it
  223. interfaces is obsolete.  For audio on the Indigo or 4D/35, see
  224. built-in module `al' above.
  225.  
  226. This module provides rudimentary access to the audio I/O device
  227. `/dev/audio' on the Silicon Graphics Personal IRIS 4D/25; see
  228. audio(7). It supports the following operations:
  229.  
  230.  -- function of module audio: setoutgain (N)
  231.      Sets the output gain.  `0 <= N < 256'.
  232.  
  233.  -- function of module audio: getoutgain ()
  234.      Returns the output gain.
  235.  
  236.  -- function of module audio: setrate (N)
  237.      Sets the sampling rate: `1' = 32K/sec, `2' = 16K/sec, `3' =
  238.      8K/sec.
  239.  
  240.  -- function of module audio: setduration (N)
  241.      Sets the `sound duration' in units of 1/100 seconds.
  242.  
  243.  -- function of module audio: read (N)
  244.      Reads a chunk of N sampled bytes from the audio input (line in or
  245.      microphone).  The chunk is returned as a string of length n. 
  246.      Each byte encodes one sample as a signed 8-bit quantity using
  247.      linear encoding.  This string can be converted to numbers using
  248.      `chr2num()' described below.
  249.  
  250.  -- function of module audio: write (BUF)
  251.      Writes a chunk of samples to the audio output (speaker).
  252.  
  253. These operations support asynchronous audio I/O:
  254.  
  255.  -- function of module audio: start_recording (N)
  256.      Starts a second thread (a process with shared memory) that begins
  257.      reading N bytes from the audio device.  The main thread
  258.      immediately continues.
  259.  
  260.  -- function of module audio: wait_recording ()
  261.      Waits for the second thread to finish and returns the data read.
  262.  
  263.  -- function of module audio: stop_recording ()
  264.      Makes the second thread stop reading as soon as possible. 
  265.      Returns the data read so far.
  266.  
  267.  -- function of module audio: poll_recording ()
  268.      Returns true if the second thread has finished reading (so
  269.      `wait_recording()' would return the data without delay).
  270.  
  271.  -- function of module audio: start_playing ()
  272.  
  273.  -- function of module audio: wait_playing ()
  274.  
  275.  -- function of module audio: stop_playing ()
  276.  
  277.  -- function of module audio: poll_playing ()
  278.      Similar but for output.  `stop_playing()' returns a lower bound
  279.      for the number of bytes actually played (not very accurate).
  280.  
  281.  
  282. The following operations do not affect the audio device but are
  283. implemented in C for efficiency:
  284.  
  285.  -- function of module audio: amplify (BUF, F1, F2)
  286.      Amplifies a chunk of samples by a variable factor changing from
  287.      `F1/256' to `F2/256.' Negative factors are allowed.  Resulting
  288.      values that are to large to fit in a byte are clipped.
  289.  
  290.  -- function of module audio: reverse (BUF)
  291.      Returns a chunk of samples backwards.
  292.  
  293.  -- function of module audio: add (BUF1, BUF2)
  294.      Bytewise adds two chunks of samples.  Bytes that exceed the range
  295.      are clipped.  If one buffer is shorter, it is assumed to be
  296.      padded with zeros.
  297.  
  298.  -- function of module audio: chr2num (BUF)
  299.      Converts a string of sampled bytes as returned by `read()' into a
  300.      list containing the numeric values of the samples.
  301.  
  302.  -- function of module audio: num2chr (LIST)
  303.      Converts a list as returned by `chr2num()' back to a buffer
  304.      acceptable by `write()'.
  305.  
  306.  
  307. 
  308. File: python-lib.info,  Node: gl,  Next: fm,  Prev: audio,  Up: SGI MACHINES ONLY
  309.  
  310. Built-in Module `gl'
  311. ====================
  312.  
  313. This module provides access to the Silicon Graphics *Graphics Library*. 
  314. It is available only on Silicon Graphics machines.
  315.  
  316. *Warning:* Some illegal calls to the GL library cause the Python
  317. interpreter to dump core.  In particular, the use of most GL calls is
  318. unsafe before the first window is opened.
  319.  
  320. The module is too large to document here in its entirety, but the
  321. following should help you to get started.  The parameter conventions
  322. for the C functions are translated to Python as follows:
  323.  
  324.    * All (short, long, unsigned) int values are represented by Python
  325.      integers.
  326.  
  327.    * All float and double values are represented by Python floating
  328.      point numbers.  In most cases, Python integers are also allowed.
  329.  
  330.    * All arrays are represented by one-dimensional Python lists.  In
  331.      most cases, tuples are also allowed.
  332.  
  333.    * All string and character arguments are represented by Python
  334.      strings, for instance, `winopen('Hi There!')' and `rotate(900,
  335.      'z')'.
  336.  
  337.    * All (short, long, unsigned) integer arguments or return values
  338.      that are only used to specify the length of an array argument are
  339.      omitted.  For example, the C call
  340.  
  341.           lmdef(deftype, index, np, props)
  342.      is translated to Python as
  343.  
  344.           lmdef(deftype, index, props)
  345.  
  346.    * Output arguments are omitted from the argument list; they are
  347.      transmitted as function return values instead.  If more than one
  348.      value must be returned, the return value is a tuple.  If the C
  349.      function has both a regular return value (that is not omitted
  350.      because of the previous rule) and an output argument, the return
  351.      value comes first in the tuple.  Examples: the C call
  352.  
  353.           getmcolor(i, &red, &green, &blue)
  354.      is translated to Python as
  355.  
  356.           red, green, blue = getmcolor(i)
  357.  
  358. The following functions are non-standard or have special argument
  359. conventions:
  360.  
  361.  -- function of module gl: varray (ARGUMENT)
  362.      Equivalent to but faster than a number of `v3d()' calls.  The
  363.      ARGUMENT is a list (or tuple) of points.  Each point must be a
  364.      tuple of coordinates `(X, Y, Z)' or `(X, Y)'.  The points may be
  365.      2- or 3-dimensional but must all have the same dimension.  Float
  366.      and int values may be mixed however.  The points are always
  367.      converted to 3D double precision points by assuming `Z = 0.0' if
  368.      necessary (as indicated in the man page), and for each point
  369.      `v3d()' is called.
  370.  
  371.  -- function of module gl: nvarray ()
  372.      Equivalent to but faster than a number of `n3f' and `v3f' calls. 
  373.      The argument is an array (list or tuple) of pairs of normals and
  374.      points.  Each pair is a tuple of a point and a normal for that
  375.      point.  Each point or normal must be a tuple of coordinates `(X,
  376.      Y, Z)'.  Three coordinates must be given.  Float and int values
  377.      may be mixed.  For each pair, `n3f()' is called for the normal,
  378.      and then `v3f()' is called for the point.
  379.  
  380.  -- function of module gl: vnarray ()
  381.      Similar to `nvarray()' but the pairs have the point first and the
  382.      normal second.
  383.  
  384.  -- function of module gl: nurbssurface (S_K, T_K, CTL, S_ORD, T_ORD,
  385.           TYPE)
  386.      Defines a nurbs surface.  The dimensions of `CTL[][]' are
  387.      computed as follows: `[len(S_K) - S_ORD]', `[len(T_K) - T_ORD]'.
  388.  
  389.  -- function of module gl: nurbscurve (KNOTS, CTLPOINTS, ORDER, TYPE)
  390.      Defines a nurbs curve.  The length of ctlpoints is `len(KNOTS) -
  391.      ORDER'.
  392.  
  393.  -- function of module gl: pwlcurve (POINTS, TYPE)
  394.      Defines a piecewise-linear curve.  POINTS is a list of points. 
  395.      TYPE must be `N_ST'.
  396.  
  397.  -- function of module gl: pick (N)
  398.  
  399.  -- function of module gl: select (N)
  400.      The only argument to these functions specifies the desired size
  401.      of the pick or select buffer.
  402.  
  403.  -- function of module gl: endpick ()
  404.  
  405.  -- function of module gl: endselect ()
  406.      These functions have no arguments.  They return a list of
  407.      integers representing the used part of the pick/select buffer. 
  408.      No method is provided to detect buffer overrun.
  409.  
  410. Here is a tiny but complete example GL program in Python:
  411.  
  412.      import gl, GL, time
  413.      
  414.      def main():
  415.          gl.foreground()
  416.          gl.prefposition(500, 900, 500, 900)
  417.          w = gl.winopen('CrissCross')
  418.          gl.ortho2(0.0, 400.0, 0.0, 400.0)
  419.          gl.color(GL.WHITE)
  420.          gl.clear()
  421.          gl.color(GL.RED)
  422.          gl.bgnline()
  423.          gl.v2f(0.0, 0.0)
  424.          gl.v2f(400.0, 400.0)
  425.          gl.endline()
  426.          gl.bgnline()
  427.          gl.v2f(400.0, 0.0)
  428.          gl.v2f(0.0, 400.0)
  429.          gl.endline()
  430.          time.sleep(5)
  431.      
  432.      main()
  433.  
  434. 
  435. File: python-lib.info,  Node: fm,  Next: Standard Modules GL and DEVICE,  Prev: gl,  Up: SGI MACHINES ONLY
  436.  
  437. Built-in Module `fm'
  438. ====================
  439.  
  440. This module provides access to the IRIS *Font Manager* library.  It is
  441. available only on Silicon Graphics machines.  See also: 4Sight User's
  442. Guide, Section 1, Chapter 5: Using the IRIS Font Manager.
  443.  
  444. This is not yet a full interface to the IRIS Font Manager.  Among the
  445. unsupported features are: matrix operations; cache operations;
  446. character operations (use string operations instead); some details of
  447. font info; individual glyph metrics; and printer matching.
  448.  
  449. It supports the following operations:
  450.  
  451.  -- function of module fm: init ()
  452.      Initialization function.  Calls `fminit()'.  It is normally not
  453.      necessary to call this function, since it is called automatically
  454.      the first time the `fm' module is imported.
  455.  
  456.  -- function of module fm: findfont (FONTNAME)
  457.      Return a font handle object.  Calls `fmfindfont(FONTNAME)'.
  458.  
  459.  -- function of module fm: enumerate ()
  460.      Returns a list of available font names.  This is an interface to
  461.      `fmenumerate()'.
  462.  
  463.  -- function of module fm: prstr (STRING)
  464.      Render a string using the current font (see the `setfont()' font
  465.      handle method below).  Calls `fmprstr(STRING)'.
  466.  
  467.  -- function of module fm: setpath (STRING)
  468.      Sets the font search path.  Calls `fmsetpath(string)'.  (XXX Does
  469.      not work!?!)
  470.  
  471.  -- function of module fm: fontpath ()
  472.      Returns the current font search path.
  473.  
  474. Font handle objects support the following operations:
  475.  
  476.  -- Method on font handle: scalefont (FACTOR)
  477.      Returns a handle for a scaled version of this font.  Calls
  478.      `fmscalefont(FH, FACTOR)'.
  479.  
  480.  -- Method on font handle: setfont ()
  481.      Makes this font the current font.  Note: the effect is undone
  482.      silently when the font handle object is deleted.  Calls
  483.      `fmsetfont(FH)'.
  484.  
  485.  -- Method on font handle: getfontname ()
  486.      Returns this font's name.  Calls `fmgetfontname(FH)'.
  487.  
  488.  -- Method on font handle: getcomment ()
  489.      Returns the comment string associated with this font.  Raises an
  490.      exception if there is none.  Calls `fmgetcomment(FH)'.
  491.  
  492.  -- Method on font handle: getfontinfo ()
  493.      Returns a tuple giving some pertinent data about this font.  This
  494.      is an interface to `fmgetfontinfo()'.  The returned tuple
  495.      contains the following numbers: `(PRINTERMATCHED, FIXED_WIDTH,
  496.      XORIG, YORIG, XSIZE, YSIZE, HEIGHT, NGLYPHS)'.
  497.  
  498.  -- Method on font handle: getstrwidth (STRING)
  499.      Returns the width, in pixels, of the string when drawn in this
  500.      font.  Calls `fmgetstrwidth(FH, STRING)'.
  501.  
  502. 
  503. File: python-lib.info,  Node: Standard Modules GL and DEVICE,  Next: fl,  Prev: fm,  Up: SGI MACHINES ONLY
  504.  
  505. Standard Modules `GL' and `DEVICE'
  506. ==================================
  507.  
  508. These modules define the constants used by the Silicon Graphics
  509. *Graphics Library* that C programmers find in the header files
  510. `<gl/gl.h>' and `<gl/device.h>'.  Read the module source files for
  511. details.
  512.  
  513. 
  514. File: python-lib.info,  Node: fl,  Next: FL (uppercase),  Prev: Standard Modules GL and DEVICE,  Up: SGI MACHINES ONLY
  515.  
  516. Built-in Module `fl'
  517. ====================
  518.  
  519. This module provides an interface to the FORMS Library by Mark
  520. Overmars, version 2.0b.  For more info about FORMS, write to
  521. markov@cs.ruu.nl.
  522.  
  523. Most functions are literal translations of their C equivalents,
  524. dropping the initial `fl_' from their name.  Constants used by the
  525. library are defined in module `FL' described below.
  526.  
  527. The creation of objects is a little different in Python than in C:
  528. instead of the `current form' maintained by the library to which new
  529. FORMS objects are added, all functions that add a FORMS object to a
  530. button are methods of the Python object representing the form. 
  531. Consequently, there are no Python equivalents for the C functions
  532. `fl_addto_form' and `fl_end_form', and the equivalent of `fl_bgn_form'
  533. is called `fl.make_form'.
  534.  
  535. Watch out for the somewhat confusing terminology: FORMS uses the word
  536. "object" for the buttons, sliders etc. that you can place in a form. 
  537. In Python, `object' means any value.  The Python interface to FORMS
  538. introduces two new Python object types: form objects (representing an
  539. entire form) and FORMS objects (representing one button, slider etc.). 
  540. Hopefully this isn't too confusing...
  541.  
  542. There are no `free objects' in the Python interface to FORMS, nor is
  543. there an easy way to add object classes written in Python.  The FORMS
  544. interface to GL event handling is avaiable, though, so you can mix
  545. FORMS with pure GL windows.
  546.  
  547. *Please note:* importing `fl' implies a call to the GL function
  548. `foreground()' and to the FORMS routine `fl_init()'.
  549.  
  550. * Menu:
  551.  
  552. * Functions defined in module fl::  Functions defined in module `fl'
  553. * Form object::                 Form object methods and data attributes
  554. * FORMS object::                FORMS object methods and data attributes
  555.  
  556. 
  557. File: python-lib.info,  Node: Functions defined in module fl,  Next: Form object,  Up: fl
  558.  
  559. Functions defined in module `fl'
  560. --------------------------------
  561.  
  562. Module `fl' defines the following functions.  For more information
  563. about what they do, see the description of the equivalent C function
  564. in the FORMS documentation:
  565.  
  566.  -- function of module fl: make_form (TYPE, WIDTH, HEIGHT)
  567.      Create a form with given type, width and height.  This returns a
  568.      "form" object, whose methods are described below.
  569.  
  570.  -- function of module fl: do_forms ()
  571.      The standard FORMS main loop.  Returns a Python object
  572.      representing the FORMS object needing interaction, or the special
  573.      value `FL.EVENT'.
  574.  
  575.  -- function of module fl: check_forms ()
  576.      Check for FORMS events.  Returns what `do_forms' above returns,
  577.      or `None' if there is no event that immediately needs interaction.
  578.  
  579.  -- function of module fl: set_event_call_back (FUNCTION)
  580.      Set the event callback function.
  581.  
  582.  -- function of module fl: set_graphics_mode (RGBMODE, DOUBLEBUFFERING)
  583.      Set the graphics modes.
  584.  
  585.  -- function of module fl: get_rgbmode ()
  586.      Return the current rgb mode.  This is the value of the C global
  587.      variable `fl_rgbmode'.
  588.  
  589.  -- function of module fl: show_message (STR1, STR2, STR3)
  590.      Show a dialog box with a three-line message and an OK button.
  591.  
  592.  -- function of module fl: show_question (STR1, STR2, STR3)
  593.      Show a dialog box with a three-line message and YES and NO
  594.      buttons.  It returns `1' if the user pressed YES, `0' if NO.
  595.  
  596.  -- function of module fl: show_choice (STR1, STR2, STR3, BUT1, BUT2,
  597.           BUT3)
  598.      Show a dialog box with a three-line message and up to three
  599.      buttons.  It returns the number of the button clicked by the user
  600.      (`1', `2' or `3').  The BUT2 and BUT3 arguments are optional.
  601.  
  602.  -- function of module fl: show_input (PROMPT, DEFAULT)
  603.      Show a dialog box with a one-line prompt message and text field in
  604.      which the user can enter a string.  The second argument is the
  605.      default input string.  It returns the string value as edited by
  606.      the user.
  607.  
  608.  -- function of module fl: show_file_selector (MESSAGE, DIRECTORY,
  609.           PATTERN, DEFAULT)
  610.      Show a dialog box inm which the user can select a file.  It
  611.      returns the absolute filename selected by the user, or `None' if
  612.      the user presses Cancel.
  613.  
  614.  -- function of module fl: get_directory ()
  615.  
  616.  -- function of module fl: get_pattern ()
  617.  
  618.  -- function of module fl: get_filename ()
  619.      These functions return the directory, pattern and filename (the
  620.      tail part only) selected by the user in the last
  621.      `show_file_selector' call.
  622.  
  623.  -- function of module fl: qdevice (DEV)
  624.  
  625.  -- function of module fl: unqdevice (DEV)
  626.  
  627.  -- function of module fl: isqueued (DEV)
  628.  
  629.  -- function of module fl: qtest ()
  630.  
  631.  -- function of module fl: qread ()
  632.  
  633.  -- function of module fl: qreset ()
  634.  
  635.  -- function of module fl: qenter (DEV, VAL)
  636.  
  637.  -- function of module fl: get_mouse ()
  638.  
  639.  -- function of module fl: tie (BUTTON, VALUATOR1, VALUATOR2)
  640.      These functions are the FORMS interfaces to the corresponding GL
  641.      functions.  Use these if you want to handle some GL events
  642.      yourself when using `fl.do_events'.  When a GL event is detected
  643.      that FORMS cannot handle, `fl.do_forms()' returns the special
  644.      value `FL.EVENT' and you should call `fl.qread()' to read the
  645.      event from the queue.  Don't use the equivalent GL functions!
  646.  
  647.  -- function of module fl: color ()
  648.  
  649.  -- function of module fl: mapcolor ()
  650.  
  651.  -- function of module fl: getmcolor ()
  652.      See the description in the FORMS documentation of `fl_color',
  653.      `fl_mapcolor' and `fl_getmcolor'.
  654.  
  655. 
  656. File: python-lib.info,  Node: Form object,  Next: FORMS object,  Prev: Functions defined in module fl,  Up: fl
  657.  
  658. Form object methods and data attributes
  659. ---------------------------------------
  660.  
  661. Form objects (returned by `fl.make_form()' above) have the following
  662. methods.  Each method corresponds to a C function whose name is
  663. prefixed with `fl_'; and whose first argument is a form pointer;
  664. please refer to the official FORMS documentation for descriptions.
  665.  
  666. All the `add_...' functions return a Python object representing the
  667. FORMS object.  Methods of FORMS objects are described below.  Most
  668. kinds of FORMS object also have some methods specific to that kind;
  669. these methods are listed here.
  670.  
  671.  -- Method on form object: show_form (PLACEMENT, BORDERTYPE, NAME)
  672.      Show the form.
  673.  
  674.  -- Method on form object: hide_form ()
  675.      Hide the form.
  676.  
  677.  -- Method on form object: redraw_form ()
  678.      Redraw the form.
  679.  
  680.  -- Method on form object: set_form_position (X, Y)
  681.      Set the form's position.
  682.  
  683.  -- Method on form object: freeze_form ()
  684.      Freeze the form.
  685.  
  686.  -- Method on form object: unfreeze_form ()
  687.      Unfreeze the form.
  688.  
  689.  -- Method on form object: activate_form ()
  690.      Activate the form.
  691.  
  692.  -- Method on form object: deactivate_form ()
  693.      Deactivate the form.
  694.  
  695.  -- Method on form object: bgn_group ()
  696.      Begin a new group of objects; return a group object.
  697.  
  698.  -- Method on form object: end_group ()
  699.      End the current group of objects.
  700.  
  701.  -- Method on form object: find_first ()
  702.      Find the first object in the form.
  703.  
  704.  -- Method on form object: find_last ()
  705.      Find the last object in the form.
  706.  
  707.  -- Method on form object: add_box (TYPE, X, Y, W, H, NAME)
  708.      Add a box object to the form.  No extra methods.
  709.  
  710.  -- Method on form object: add_text (TYPE, X, Y, W, H, NAME)
  711.      Add a text object to the form.  No extra methods.
  712.  
  713.  -- Method on form object: add_clock (TYPE, X, Y, W, H, NAME)
  714.      Add a clock object to the form. 
  715.       Method: `get_clock'.
  716.  
  717.  -- Method on form object: add_button (TYPE, X, Y, W, H, NAME)
  718.      Add a button object to the form. 
  719.       Methods: `get_button', `set_button'.
  720.  
  721.  -- Method on form object: add_lightbutton (TYPE, X, Y, W, H, NAME)
  722.      Add a lightbutton object to the form. 
  723.       Methods: `get_button', `set_button'.
  724.  
  725.  -- Method on form object: add_roundbutton (TYPE, X, Y, W, H, NAME)
  726.      Add a roundbutton object to the form. 
  727.       Methods: `get_button', `set_button'.
  728.  
  729.  -- Method on form object: add_slider (TYPE, X, Y, W, H, NAME)
  730.      Add a slider object to the form. 
  731.       Methods: `set_slider_value', `get_slider_value',
  732.      `set_slider_bounds', `get_slider_bounds', `set_slider_return',
  733.      `set_slider_size', `set_slider_precision', `set_slider_step'.
  734.  
  735.  -- Method on form object: add_valslider (TYPE, X, Y, W, H, NAME)
  736.      Add a valslider object to the form. 
  737.       Methods: `set_slider_value', `get_slider_value',
  738.      `set_slider_bounds', `get_slider_bounds', `set_slider_return',
  739.      `set_slider_size', `set_slider_precision', `set_slider_step'.
  740.  
  741.  -- Method on form object: add_dial (TYPE, X, Y, W, H, NAME)
  742.      Add a dial object to the form. 
  743.       Methods: `set_dial_value', `get_dial_value', `set_dial_bounds',
  744.      `get_dial_bounds'.
  745.  
  746.  -- Method on form object: add_positioner (TYPE, X, Y, W, H, NAME)
  747.      Add a positioner object to the form. 
  748.       Methods: `set_positioner_xvalue', `set_positioner_yvalue',
  749.      `set_positioner_xbounds', `set_positioner_ybounds',
  750.      `get_positioner_xvalue', `get_positioner_yvalue',
  751.      `get_positioner_xbounds', `get_positioner_ybounds'.
  752.  
  753.  -- Method on form object: add_counter (TYPE, X, Y, W, H, NAME)
  754.      Add a counter object to the form. 
  755.       Methods: `set_counter_value', `get_counter_value',
  756.      `set_counter_bounds', `set_counter_step', `set_counter_precision',
  757.      `set_counter_return'.
  758.  
  759.  -- Method on form object: add_input (TYPE, X, Y, W, H, NAME)
  760.      Add a input object to the form. 
  761.       Methods: `set_input', `get_input', `set_input_color',
  762.      `set_input_return'.
  763.  
  764.  -- Method on form object: add_menu (TYPE, X, Y, W, H, NAME)
  765.      Add a menu object to the form. 
  766.       Methods: `set_menu', `get_menu', `addto_menu'.
  767.  
  768.  -- Method on form object: add_choice (TYPE, X, Y, W, H, NAME)
  769.      Add a choice object to the form. 
  770.       Methods: `set_choice', `get_choice', `clear_choice',
  771.      `addto_choice', `replace_choice', `delete_choice',
  772.      `get_choice_text', `set_choice_fontsize', `set_choice_fontstyle'.
  773.  
  774.  -- Method on form object: add_browser (TYPE, X, Y, W, H, NAME)
  775.      Add a browser object to the form. 
  776.       Methods: `set_browser_topline', `clear_browser',
  777.      `add_browser_line', `addto_browser', `insert_browser_line',
  778.      `delete_browser_line', `replace_browser_line', `get_browser_line',
  779.      `load_browser', `get_browser_maxline', `select_browser_line',
  780.      `deselect_browser_line', `deselect_browser',
  781.      `isselected_browser_line', `get_browser', `set_browser_fontsize',
  782.      `set_browser_fontstyle', `set_browser_specialkey'.
  783.  
  784.  -- Method on form object: add_timer (TYPE, X, Y, W, H, NAME)
  785.      Add a timer object to the form. 
  786.       Methods: `set_timer', `get_timer'.
  787.  
  788. Form objects have the following data attributes; see the FORMS
  789. documentation:
  790.  
  791. *Name*
  792.      *Type*  --  *Meaning*
  793.  
  794. `window'
  795.      int (read-only)  --  GL window id
  796.  
  797. `w'
  798.      float  --  form width
  799.  
  800. `h'
  801.      float  --  form height
  802.  
  803. `x'
  804.      float  --  form x origin
  805.  
  806. `y'
  807.      float  --  form y origin
  808.  
  809. `deactivated'
  810.      int  --  nonzero if form is deactivated
  811.  
  812. `visible'
  813.      int  --  nonzero if form is visible
  814.  
  815. `frozen'
  816.      int  --  nonzero if form is frozen
  817.  
  818. `doublebuf'
  819.      int  --  nonzero if double buffering on
  820.  
  821. 
  822. File: python-lib.info,  Node: FORMS object,  Prev: Form object,  Up: fl
  823.  
  824. FORMS object methods and data attributes
  825. ----------------------------------------
  826.  
  827. Besides methods specific to particular kinds of FORMS objects, all
  828. FORMS objects also have the following methods:
  829.  
  830.  -- Method on FORMS object: set_call_back (FUNCTION, ARGUMENT)
  831.      Set the object's callback function and argument.  When the object
  832.      needs interaction, the callback function will be called with two
  833.      arguments: the object, and the callback argument.  (FORMS objects
  834.      without a callback function are returned by `fl.do_forms()' or
  835.      `fl.check_forms()' when they need interaction.)  Call this method
  836.      without arguments to remove the callback function.
  837.  
  838.  -- Method on FORMS object: delete_object ()
  839.      Delete the object.
  840.  
  841.  -- Method on FORMS object: show_object ()
  842.      Show the object.
  843.  
  844.  -- Method on FORMS object: hide_object ()
  845.      Hide the object.
  846.  
  847.  -- Method on FORMS object: redraw_object ()
  848.      Redraw the object.
  849.  
  850.  -- Method on FORMS object: freeze_object ()
  851.      Freeze the object.
  852.  
  853.  -- Method on FORMS object: unfreeze_object ()
  854.      Unfreeze the object.
  855.  
  856. FORMS objects have these data attributes; see the FORMS documentation:
  857.  
  858. *Name*
  859.      *Type*  --  *Meaning*
  860.  
  861. `objclass'
  862.      int (read-only)  --  object class
  863.  
  864. `type'
  865.      int (read-only)  --  object type
  866.  
  867. `boxtype'
  868.      int  --  box type
  869.  
  870. `x'
  871.      float  --  x origin
  872.  
  873. `y'
  874.      float  --  y origin
  875.  
  876. `w'
  877.      float  --  width
  878.  
  879. `h'
  880.      float  --  height
  881.  
  882. `col1'
  883.      int  --  primary color
  884.  
  885. `col2'
  886.      int  --  secondary color
  887.  
  888. `align'
  889.      int  --  alignment
  890.  
  891. `lcol'
  892.      int  --  label color
  893.  
  894. `lsize'
  895.      float  --  label font size
  896.  
  897. `label'
  898.      string  --  label string
  899.  
  900. `lstyle'
  901.      int  --  label style
  902.  
  903. `pushed'
  904.      int (read-only)  --  (see FORMS docs)
  905.  
  906. `focus'
  907.      int (read-only)  --  (see FORMS docs)
  908.  
  909. `belowmouse'
  910.      int (read-only)  --  (see FORMS docs)
  911.  
  912. `frozen'
  913.      int (read-only)  --  (see FORMS docs)
  914.  
  915. `active'
  916.      int (read-only)  --  (see FORMS docs)
  917.  
  918. `input'
  919.      int (read-only)  --  (see FORMS docs)
  920.  
  921. `visible'
  922.      int (read-only)  --  (see FORMS docs)
  923.  
  924. `radio'
  925.      int (read-only)  --  (see FORMS docs)
  926.  
  927. `automatic'
  928.      int (read-only)  --  (see FORMS docs)
  929.  
  930. 
  931. File: python-lib.info,  Node: FL (uppercase),  Next: flp,  Prev: fl,  Up: SGI MACHINES ONLY
  932.  
  933. Standard Module `FL'
  934. ====================
  935.  
  936. This module defines symbolic constants needed to use the built-in
  937. module `fl' (see above); they are equivalent to those defined in the C
  938. header file `<forms.h>' except that the name prefix `FL_' is omitted. 
  939. Read the module source for a complete list of the defined names. 
  940. Suggested use:
  941.  
  942.      import fl
  943.      from FL import *
  944.  
  945. 
  946. File: python-lib.info,  Node: flp,  Next: panel,  Prev: FL (uppercase),  Up: SGI MACHINES ONLY
  947.  
  948. Standard Module `flp'
  949. =====================
  950.  
  951. This module defines functions that can read form definitions created
  952. by the `form designer' (`fdesign') program that comes with the FORMS
  953. library (see module `fl' above).
  954.  
  955. For now, see the file `flp.doc' in the Python library source directory
  956. for a description.
  957.  
  958. XXX A complete description should be inserted here!
  959.  
  960. 
  961. File: python-lib.info,  Node: panel,  Next: panelparser,  Prev: flp,  Up: SGI MACHINES ONLY
  962.  
  963. Standard Module `panel'
  964. =======================
  965.  
  966. *Please note:* The FORMS library, to which the `fl' module described
  967. above interfaces, is a simpler and more accessible user interface
  968. library for use with GL than the Panel Module (besides also being by a
  969. Dutch author).
  970.  
  971. This module should be used instead of the built-in module `pnl' to
  972. interface with the *Panel Library*.
  973.  
  974. The module is too large to document here in its entirety.  One
  975. interesting function:
  976.  
  977.  -- function of module panel: defpanellist (FILENAME)
  978.      Parses a panel description file containing S-expressions written
  979.      by the *Panel Editor* that accompanies the Panel Library and
  980.      creates the described panels.  It returns a list of panel objects.
  981.  
  982. *Warning:* the Python interpreter will dump core if you don't create a
  983. GL window before calling `panel.mkpanel()' or `panel.defpanellist()'.
  984.  
  985. 
  986. File: python-lib.info,  Node: panelparser,  Next: pnl,  Prev: panel,  Up: SGI MACHINES ONLY
  987.  
  988. Standard Module `panelparser'
  989. =============================
  990.  
  991. This module defines a self-contained parser for S-expressions as output
  992. by the Panel Editor (which is written in Scheme so it can't help
  993. writing S-expressions).  The relevant function is
  994. `panelparser.parse_file(FILE)' which has a file object (not a
  995. filename!) as argument and returns a list of parsed S-expressions. 
  996. Each S-expression is converted into a Python list, with atoms converted
  997. to Python strings and sub-expressions (recursively) to Python lists. 
  998. For more details, read the module file.
  999.  
  1000. 
  1001. File: python-lib.info,  Node: pnl,  Next: jpeg,  Prev: panelparser,  Up: SGI MACHINES ONLY
  1002.  
  1003. Built-in Module `pnl'
  1004. =====================
  1005.  
  1006. This module provides access to the *Panel Library* built by NASA Ames
  1007. (to get it, send e-mail to panel-request@nas.nasa.gov).  All access to
  1008. it should be done through the standard module `panel', which
  1009. transparantly exports most functions from `pnl' but redefines
  1010. `pnl.dopanel()'.
  1011.  
  1012. *Warning:* the Python interpreter will dump core if you don't create a
  1013. GL window before calling `pnl.mkpanel()'.
  1014.  
  1015. The module is too large to document here in its entirety.
  1016.  
  1017. 
  1018. File: python-lib.info,  Node: jpeg,  Next: imgfile,  Prev: pnl,  Up: SGI MACHINES ONLY
  1019.  
  1020. Built-in Module `jpeg'
  1021. ======================
  1022.  
  1023. The module jpeg provides access to the jpeg compressor and
  1024. decompressor written by the Independent JPEG Group. JPEG is a (draft?)
  1025. standard for compressing pictures.  For details on jpeg or the
  1026. Indepent JPEG Group software refer to the JPEG standard or the
  1027. documentation provided with the software.
  1028.  
  1029. The jpeg module defines these functions:
  1030.  
  1031.  -- function of module jpeg: compress (DATA, W, H, B)
  1032.      Treat data as a pixmap of width w and height h, with b bytes per
  1033.      pixel.  The data is in sgi gl order, so the first pixel is in the
  1034.      lower-left corner. This means that lrectread return data can
  1035.      immedeately be passed to compress.  Currently only 1 byte and 4
  1036.      byte pixels are allowed, the former being treaded as greyscale
  1037.      and the latter as RGB color.  Compress returns a string that
  1038.      contains the compressed picture, in JFIF format.
  1039.  
  1040.  -- function of module jpeg: decompress (DATA)
  1041.      Data is a string containing a picture in JFIF format. It returns a
  1042.      tuple `(DATA, WIDTH, HEIGHT, BYTESPERPIXEL)'.  Again, the data is
  1043.      suitable to pass to lrectwrite.
  1044.  
  1045.  -- function of module jpeg: setoption (NAME, VALUE)
  1046.      Set various options.  Subsequent compress and decompress calls
  1047.      will use these options.  The following options are available:
  1048.     `'forcegray''
  1049.           Force output to be grayscale, even if input is RGB.
  1050.  
  1051.     `'quality''
  1052.           Set the quality of the compressed image to a value between
  1053.           `0' and `100' (default is `75').  Compress only.
  1054.  
  1055.     `'optimize''
  1056.           Perform huffman table optimization.  Takes longer, but
  1057.           results in smaller compressed image.  Compress only.
  1058.  
  1059.     `'smooth''
  1060.           Perform inter-block smoothing on uncompressed image.  Only
  1061.           useful for low-quality images.  Decompress only.
  1062.  
  1063. Compress and uncompress raise the error jpeg.error in case of errors.
  1064.  
  1065. 
  1066. File: python-lib.info,  Node: imgfile,  Next: imageop,  Prev: jpeg,  Up: SGI MACHINES ONLY
  1067.  
  1068. Built-in module `imgfile'
  1069. =========================
  1070.  
  1071. The imgfile module allows python programs to access SGI imglib image
  1072. files (also known as `.rgb' files).  The module is far from complete,
  1073. but is provided anyway since the functionality that there is is enough
  1074. in some cases.  Currently, colormap files are not supported.
  1075.  
  1076. The module defines the following variables and functions:
  1077.  
  1078.  -- exception of module imgfile: error
  1079.      This exception is raised on all errors, such as unsupported file
  1080.      type, etc.
  1081.  
  1082.  -- function of module imgfile: getsizes (FILE)
  1083.      This function returns a tuple `(X, Y, Z)' where X and Y are the
  1084.      size of the image in pixels and Z is the number of bytes per
  1085.      pixel. Only 3 byte RGB pixels and 1 byte greyscale pixels are
  1086.      currently supported.
  1087.  
  1088.  -- function of module imgfile: read (FILE)
  1089.      This function reads and decodes the image on the specified file,
  1090.      and returns it as a python string. The string has either 1 byte
  1091.      greyscale pixels or 4 byte RGBA pixels. The bottom left pixel is
  1092.      the first in the string. This format is suitable to pass to
  1093.      `gl.lrectwrite', for instance.
  1094.  
  1095.  -- function of module imgfile: readscaled (FILE, X, Y, FILTER, BLUR)
  1096.      This function is identical to read but it returns an image that is
  1097.      scaled to the given X and Y sizes. If the FILTER and BLUR
  1098.      parameters are omitted scaling is done by simply dropping or
  1099.      duplicating pixels, so the result will be less than perfect,
  1100.      especially for computer-generated images.
  1101.  
  1102.      Alternatively, you can specify a filter to use to smoothen the
  1103.      image after scaling. The filter forms supported are `'impulse'',
  1104.      `'box'', `'triangle'', `'quadratic'' and `'gaussian''. If a
  1105.      filter is specified BLUR is an optional parameter specifying the
  1106.      blurriness of the filter. It defaults to `1.0'.
  1107.  
  1108.      Readscaled makes no attempt to keep the aspect ratio correct, so
  1109.      that is the users' responsibility.
  1110.  
  1111.  -- function of module imgfile: write (FILE, DATA, X, Y, Z)
  1112.      This function writes the RGB or greyscale data in DATA to image
  1113.      file FILE. X and Y give the size of the image, Z is 1 for 1 byte
  1114.      greyscale images or 3 for RGB images (which are stored as 4 byte
  1115.      values of which only the lower three bytes are used).  These are
  1116.      the formats returned by `gl.lrectread'.
  1117.  
  1118. 
  1119. File: python-lib.info,  Node: imageop,  Prev: imgfile,  Up: SGI MACHINES ONLY
  1120.  
  1121. Built-in module `imageop'
  1122. =========================
  1123.  
  1124. The imageop module contains some useful operations on images.  It
  1125. operates on images consisting of 8 or 32 bit pixels stored in python
  1126. strings. This is the same format as used by `gl.lrectwrite' and the
  1127. `imgfile' module.
  1128.  
  1129. The module defines the following variables and functions:
  1130.  
  1131.  -- exception of module imageop: error
  1132.      This exception is raised on all errors, such as unknown number of
  1133.      bits per pixel, etc.
  1134.  
  1135.  -- function of module imageop: crop (IMAGE, PSIZE, WIDTH, HEIGHT, X0,
  1136.           Y0, X1, Y1)
  1137.      This function takes the image in `image', which should by `width'
  1138.      by `height' in size and consist of pixels of `psize' bytes, and
  1139.      returns the selected part of that image. `X0', `y0', `x1' and
  1140.      `y1' are like the `lrectread' parameters, i.e. the boundary is
  1141.      included in the new image.  The new boundaries need not be inside
  1142.      the picture. Pixels that fall outside the old image will have
  1143.      their value set to zero.  If `x0' is bigger than `x1' the new
  1144.      image is mirrored. The same holds for the y coordinates.
  1145.  
  1146.  -- function of module imageop: scale (IMAGE, PSIZE, WIDTH, HEIGHT,
  1147.           NEWWIDTH, NEWHEIGHT)
  1148.      This function returns a `image' scaled to size `newwidth' by
  1149.      `newheight'. No interpolation is done, scaling is done by
  1150.      simple-minded pixel duplication or removal. Therefore,
  1151.      computer-generated images or dithered images will not look nice
  1152.      after scaling.
  1153.  
  1154.  -- function of module imageop: tovideo (IMAGE, PSIZE, WIDTH, HEIGHT)
  1155.      This function runs a vertical low-pass filter over an image. It
  1156.      does so by computing each destination pixel as the average of two
  1157.      vertically-aligned source pixels. The main use of this routine is
  1158.      to forestall excessive flicker if the image is displayed on a
  1159.      video device that uses interlacing, hence the name.
  1160.  
  1161.  -- function of module imageop: grey2mono (IMAGE, WIDTH, HEIGHT,
  1162.           THRESHOLD)
  1163.      This function converts a 8-bit deep greyscale image to a 1-bit
  1164.      deep image by tresholding all the pixels. The resulting image is
  1165.      tightly packed and is probably only useful as an argument to
  1166.      `mono2grey'.
  1167.  
  1168.  -- function of module imageop: dither2mono (IMAGE, WIDTH, HEIGHT)
  1169.      This function also converts an 8-bit greyscale image to a 1-bit
  1170.      monochrome image but it uses a (simple-minded) dithering
  1171.      algorithm.
  1172.  
  1173.  -- function of module imageop: mono2grey (IMAGE, WIDTH, HEIGHT, P0,
  1174.           P1)
  1175.      This function converts a 1-bit monochrome image to an 8 bit
  1176.      greyscale or color image. All pixels that are zero-valued on
  1177.      input get value `p0' on output and all one-value input pixels get
  1178.      value `p1' on output. To convert a monochrome black-and-white
  1179.      image to greyscale pass the values `0' and `255' respectively.
  1180.  
  1181.  -- function of module imageop: grey2grey4 (IMAGE, WIDTH, HEIGHT)
  1182.      Convert an 8-bit greyscale image to a 4-bit greyscale image
  1183.      without dithering.
  1184.  
  1185.  -- function of module imageop: grey2grey2 (IMAGE, WIDTH, HEIGHT)
  1186.      Convert an 8-bit greyscale image to a 2-bit greyscale image
  1187.      without dithering.
  1188.  
  1189.  -- function of module imageop: dither2grey2 (IMAGE, WIDTH, HEIGHT)
  1190.      Convert an 8-bit greyscale image to a 2-bit greyscale image with
  1191.      dithering. As for `dither2mono', the dithering algorithm is
  1192.      currently very simple.
  1193.  
  1194.  -- function of module imageop: grey42grey (IMAGE, WIDTH, HEIGHT)
  1195.      Convert a 4-bit greyscale image to an 8-bit greyscale image.
  1196.  
  1197.  -- function of module imageop: grey22grey (IMAGE, WIDTH, HEIGHT)
  1198.      Convert a 2-bit greyscale image to an 8-bit greyscale image.
  1199.  
  1200. 
  1201. File: python-lib.info,  Node: SUN SPARC MACHINES ONLY,  Next: AUDIO TOOLS,  Prev: SGI MACHINES ONLY,  Up: Top
  1202.  
  1203. SUN SPARC MACHINES ONLY
  1204. ***********************
  1205.  
  1206. * Menu:
  1207.  
  1208. * sunaudiodev::                 Built-in module `sunaudiodev'
  1209.  
  1210. 
  1211. File: python-lib.info,  Node: sunaudiodev,  Up: SUN SPARC MACHINES ONLY
  1212.  
  1213. Built-in module `sunaudiodev'
  1214. =============================
  1215.  
  1216. This module allows you to access the sun audio interface. The sun
  1217. audio hardware is capable of recording and playing back audio data in
  1218. U-LAW format with a sample rate of 8K per second. A full description
  1219. can be gotten with `man audio'.
  1220.  
  1221. The module defines the following variables and functions:
  1222.  
  1223.  -- exception of module sunaudiodev: error
  1224.      This exception is raised on all errors. The argument is a string
  1225.      describing what went wrong.
  1226.  
  1227.  -- function of module sunaudiodev: open (MODE)
  1228.      This function opens the audio device and returns a sun audio
  1229.      device object. This object can then be used to do I/O on. The
  1230.      MODE parameter is one of `'r'' for record-only access, `'w'' for
  1231.      play-only access, `'rw'' for both and `'control'' for access to
  1232.      the control device. Since only one process is allowed to have the
  1233.      recorder or player open at the same time it is a good idea to
  1234.      open the device only for the activity needed. See the audio
  1235.      manpage for details.
  1236.  
  1237. * Menu:
  1238.  
  1239. * Audio device object methods::  Audio device object methods
  1240.  
  1241. 
  1242. File: python-lib.info,  Node: Audio device object methods,  Up: sunaudiodev
  1243.  
  1244. Audio device object methods
  1245. ---------------------------
  1246.  
  1247. The audio device objects are returned by `open' define the following
  1248. methods (except `control' objects which only provide getinfo, setinfo
  1249. and drain):
  1250.  
  1251.  -- Method on audio device: close ()
  1252.      This method explicitly closes the device. It is useful in
  1253.      situations where deleting the object does not immediately close
  1254.      it since there are other references to it. A closed device should
  1255.      not be used again.
  1256.  
  1257.  -- Method on audio device: drain ()
  1258.      This method waits until all pending output is processed and then
  1259.      returns.  Calling this method is often not necessary: destroying
  1260.      the object will automatically close the audio device and this
  1261.      will do an implicit drain.
  1262.  
  1263.  -- Method on audio device: flush ()
  1264.      This method discards all pending output. It can be used avoid the
  1265.      slow response to a user's stop request (due to buffering of up to
  1266.      one second of sound).
  1267.  
  1268.  -- Method on audio device: getinfo ()
  1269.      This method retrieves status information like input and output
  1270.      volume, etc. and returns it in the form of an audio status
  1271.      object. This object has no methods but it contains a number of
  1272.      attributes describing the current device status. The names and
  1273.      meanings of the attributes are described in
  1274.      `/usr/include/sun/audioio.h' and in the audio man page. Member
  1275.      names are slightly different from their C counterparts: a status
  1276.      object is only a single structure. Members of the `play'
  1277.      substructure have `o_' prepended to their name and members of the
  1278.      `record' structure have `i_'. So, the C member `play.sample_rate'
  1279.      is accessed as `o_sample_rate', `record.gain' as `i_gain' and
  1280.      `monitor_gain' plainly as `monitor_gain'.
  1281.  
  1282.  -- Method on audio device: ibufcount ()
  1283.      This method returns the number of samples that are buffered on the
  1284.      recording side, i.e.  the program will not block on a `read' call
  1285.      of so many samples.
  1286.  
  1287.  -- Method on audio device: obufcount ()
  1288.      This method returns the number of samples buffered on the playback
  1289.      side. Unfortunately, this number cannot be used to determine a
  1290.      number of samples that can be written without blocking since the
  1291.      kernel output queue length seems to be variable.
  1292.  
  1293.  -- Method on audio device: read (SIZE)
  1294.      This method reads SIZE samples from the audio input and returns
  1295.      them as a python string. The function blocks until enough data is
  1296.      available.
  1297.  
  1298.  -- Method on audio device: setinfo (STATUS)
  1299.      This method sets the audio device status parameters. The STATUS
  1300.      parameter is an device status object as returned by `getinfo' and
  1301.      possibly modified by the program.
  1302.  
  1303.  -- Method on audio device: write (SAMPLES)
  1304.      Write is passed a python string containing audio samples to be
  1305.      played.  If there is enough buffer space free it will immedeately
  1306.      return, otherwise it will block.
  1307.  
  1308. There is a companion module, `SUNAUDIODEV', which defines useful
  1309. symbolic constants like `MIN_GAIN', `MAX_GAIN', `SPEAKER', etc. The
  1310. names of the constants are the same names as used in the C include file
  1311. `<sun/audioio.h>', with the leading string `AUDIO_' stripped.
  1312.  
  1313. Useability of the control device is limited at the moment, since there
  1314. is no way to use the 'wait for something to happen' feature the device
  1315. provides. This is because that feature makes heavy use of signals, and
  1316. these do not map too well onto Python.
  1317.  
  1318. 
  1319. File: python-lib.info,  Node: AUDIO TOOLS,  Next: CRYPTOGRAPHIC EXTENSIONS,  Prev: SUN SPARC MACHINES ONLY,  Up: Top
  1320.  
  1321. AUDIO TOOLS
  1322. ***********
  1323.  
  1324. * Menu:
  1325.  
  1326. * audioop::                     Built-in module `audioop'
  1327.  
  1328.